package com.gdk.ksoft.assembly.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.baidu.location.BDLocation;

/**
 * Created by hel on 2014-11-20.
 * 地理位置BroadcastReceiver
 */
public class LocationReceiver extends BroadcastReceiver {

    public static final String ACTION_RECIEVER = LocationReceiver.class.getSimpleName();

    public interface OnLocationListener {
        public void onTellLocation(BDLocation loc);
    }

    private OnLocationListener listener;

    public LocationReceiver(OnLocationListener listener) {
        this.listener = listener;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        if (listener != null && intent.getAction().equals(ACTION_RECIEVER)) {
            BDLocation loc = intent.getParcelableExtra("location");
            listener.onTellLocation(loc);
        }
    }
}
